package grabGroup.service;

import grabGroup.meta.PersonaMeta;
import grabGroup.model.Persona;

import java.util.List;
import java.util.Map;

import org.slim3.datastore.Datastore;
import org.slim3.util.BeanUtil;

import com.google.appengine.api.datastore.Transaction;

public class GlobalService {
    
    private PersonaMeta pm = new PersonaMeta();
    
    public Persona addPersona(Map<String, Object> input) {
        Persona p = new Persona();
        BeanUtil.copy(input, p);
        Transaction tx = Datastore.beginTransaction();
        Datastore.put(p);
        tx.commit();
        return p;
    }
    
    public List<Persona> getListPersona() {
        return Datastore.query(pm).sort(pm.nome.desc).asList();
    }

}
